﻿@{
    ViewBag.Title = "OrganizationIndex";
}
@section head
{
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/gray/easyui.css")" rel="stylesheet" />
    <link href="@Url.Content("~/ScriptPlugin/easyui/themes/icon.css")" rel="stylesheet" />
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/jquery.easyui.min.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/ScriptPlugin/easyui/locale/easyui-lang-zh_CN.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/KingsSharp.DataGrid.Filter.js")"></script>
    <script src="@Url.Content("~/ScriptPlugin/WdatePicker/js/WdatePicker.js")"></script>

}
<div id="grid" style="height:99%;">
    <div id="toolpannel">
        <div class="content-pannel-buttons">
            <a><b class="p-icon-reload">刷新 </b></a><a onclick="OrganizationAdd()">
                <b class="p-icon-add">
                    新增
                </b>
            </a><a onclick="OrganizationEdit()"><b class="p-icon-edit">编辑</b></a>
            <a onclick="OrganizationDelete()"><b class="p-icon-delete">删除</b></a>
            <a onclick="$('#grid').treegrid('load')">
                <b class="p-icon-serch">查询</b>
            </a>
        </div>
        </div>
    </div>
@section foot{
<script type="text/javascript">
    function LoadOrganizationData() {
        grid = $("#grid").treegrid({
            url: "@Url.Content("~/Sys/Organization/GetOrganizationGridData")",
            idField: 'Id',
            treeField: 'Name',
            rownumbers: true,
            toolbar: "#toolpannel",
            striped: true,
            loadMsg: "机构数据加载中......请稍候",
            title: "@Html.GetGridTitle("系统管理","机构设置")",
            columns: [[
              { field: "Name", title: "机构名称", width: 230 },
              { field: "Code", title: "机构编码", width: 80 },
                { field: "Order", title: "排序号", width: 50 },
                { field: "Remark", title: "备注信息", width: 180 }
            ]]
        });
    }
    LoadOrganizationData();

    function OrganizationAdd() {
        K.layer.iframe({
            title: "@Html.GetLayerTitle(LayerIcon.Add,"新增机构")",
            content: "@Url.Content("~/Sys/Organization/OrganizationAdd")",
            maxmin: true,
            initfull: true,
            btn: ["保存", "返回"],
            callback: function (result) {
                if (K.ShowOrAlert(result)) {
                    $("#grid").treegrid("load");
                }
            }
        });
    }
    function OrganizationEdit() {
        var row = $("#grid").treegrid("getSelected");
        if (row == null) {
            K.Alert("请选择需要编辑的行");
            return false;
        }
        K.layer.iframe({
            title: "@Html.GetLayerTitle(LayerIcon.Edit,"编辑机构")",
            content: "@Url.Content("~/Sys/Organization/OrganizationEdit")?OrganizationId=" + row.Id,
            maxmin: true,
            initfull: true,
            btn: ["保存", "返回"],
            callback: function (result) {
                if (K.ShowOrAlert(result)) {
                    $("#grid").treegrid("load");
                }
            }
        });
    }
    function OrganizationDelete() {
        var row = $("#grid").treegrid("getSelected");
        if (row == null) {
            K.Alert("请选择需要删除的行");
            return false;
        }
        K.Confirm("是否确认删除 \"" + row.Name + "\" ？", function () {
            K.AjaxJson("@Url.Content("~/Sys/Organization/OrganizationDelete")", { OrganizationId: row.Id, OrganizationName: row.Name }, function (result) {
                if(K.ShowOrAlert(result))
                {
                    $("#grid").treegrid("load");
                }
            });
        });
    }
</script>
}